package com.zhh.shiro;

import com.zhh.common.redis.RedisClient;
import com.zhh.jwt.JWTUtil;
import org.apache.shiro.cache.Cache;
import org.apache.shiro.cache.CacheException;
import org.apache.shiro.cache.CacheManager;

public class CustomCacheManager implements CacheManager {

    private RedisClient redis;

    private JWTUtil jwtUtil;

    public CustomCacheManager(RedisClient redis,JWTUtil jwtUtil){
        this.jwtUtil = jwtUtil;
        this.redis =redis;
    }

    @Override
    public <K, V> Cache<K, V> getCache(String s) throws CacheException {
        CustomCache<K, V> customCache = new CustomCache<K, V>();
        customCache.setRedisAndJWTUtil(redis,jwtUtil);
        return customCache;
    }
}
